from django.db import models


# Create your models here.


class UserModel(models.Model):
    username = models.CharField(max_length=30)
    password = models.CharField(max_length=128)

    class Meta:
        db_table = 'user'

    def __str__(self):
        return self.username


class CateModel(models.Model):
    cate_name = models.CharField(max_length=30)

    class Meta:
        db_table = 'cate'

    def __str__(self):
        return self.cate_name


class NewsModel(models.Model):
    title = models.CharField(max_length=50, verbose_name='新闻标题')
    content = models.TextField(verbose_name='新闻内容')
    stars = models.IntegerField(verbose_name='点赞数')
    cate = models.ForeignKey(CateModel, on_delete=models.CASCADE, verbose_name='新闻分类')

    class Meta:
        db_table = 'news'

    def __str__(self):
        return self.title
